<?php

namespace app\models\Child;

use Yii;

/**
 * This is the model class for table "t_order_service_detail".
 *
 * @property integer $rel_id
 * @property string $booking_no
 * @property integer $order_id
 * @property string $order_no
 * @property integer $service_type
 * @property integer $service_id
 * @property string $cashier_id
 * @property string $user_id
 * @property string $doctor_id
 * @property string $subclinic_id
 * @property integer $patient_id
 * @property integer $order_num
 * @property string $service_name
 * @property string $service_img
 * @property string $service_cost
 * @property string $service_income
 * @property string $service_sum_cost
 * @property string $service_sum_income
 * @property string $create_time
 */
class TPatientInfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_patient_info';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['patient_id', 'user_id', 'patient_age', 'patient_gender', 'patient_height','patient_body_weight'], 'integer'],
            [['create_time'], 'safe'],
            [['patient_name'], 'string', 'max' => 50],
            [['patient_img'], 'string', 'max' => 500],
            [['patient_address'], 'string', 'max' => 100],
            [['patient_desc'], 'string', 'max' => 300],
            [['patient_birthday'], 'string', 'max' => 20],
            [['patient_card'], 'string', 'max' => 30]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'patient_id' => 'Patient ID',
            'user_id' => 'User Id',
            'patient_age' => 'Patient Age',
            'patient_gender' => 'Patient Gender',
            'patient_height' => 'Patient Height',
            'patient_body_weight' => 'Patient Body Weight',
            'patient_name' => 'Patient Name',
            'patient_img' => 'Patient Img',
            'patient_address' => 'Patient Address',
            'patient_desc' => 'Patient Desc',
            'patient_id' => 'Patient Id',
            'patient_card' => 'Patient Card',
            'create_time' => 'Create Time'
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUserPatientList($user_id)
    {
        $list = $this->find()
            ->select('patient_id,user_id,patient_name,patient_img,patient_age,patient_gender,patient_height,patient_body_weight,patient_address,patient_desc,patient_birthday')
            ->where(['user_id' => $user_id])
            ->asArray()
            ->all();
        return $list;
    }
}
